<?php
    use User\Model\DailySignModel;
?>
<style>
    .table>thead>tr>th{text-align: center}
    .table>tbody>tr>td{vertical-align: middle;text-align: center}
    .table>tbody>tr>td>a{margin-top:5px}
    .btn-custom{color:white} .btn-custom:hover{color:white}
    .color1{background-color:#199ED8} .color2{background-color:#999933} .color3{background-color:#5CB85C}
    .color4{background-color:#F0AD4E} .color5{background-color:#D9534F} .color6{background-color:#FFCC33}
    .color7{background-color:#FF66CC} .color8{background-color:#66CCFF} .color9{background-color:#660000}
</style>
<div class="page-heading">
    <h3>心情日历签</h3>
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="panel">
            <div class="panel-heading">
                <a style="margin-left:7px" href="/User/DailySign/edit" class="btn btn-custom color3">新增</a>
            </div>
            <div class="panel-body">
                <div class="col-lg-12">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>链接首页地址</th>
                                <th>状态</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <volist name="list" id="item">
                                <tr>
                                    <td>{$item.id}</td>
                                    <td>{$item.title}</td>
                                    <td>{$item.link}</td>
                                    <td>
                                        <if condition="$item.status eq DailySignModel::SIGN_STATUS_ACTIVE">
                                            <span class="label color3">已发布</span>
                                        <else/>
                                            <span class="label color6">停用</span>
                                        </if>
                                    </td>
                                    <td>{$item.createdate}</td>
                                    <td>
                                        <a type="button" href="/User/DailySign/edit?id={$item['id']}" class="btn btn-custom color1">编辑</a>
                                        <if condition="$item.status eq DailySignModel::SIGN_STATUS_ACTIVE">
                                            <a type="button" href="javascript:;" onclick="return statusDailySign({$item['id']}, 'stop');" class="btn btn-custom color2">停用</a>
                                        <else/>
                                            <a type="button" href="javascript:;" onclick="return statusDailySign({$item['id']}, 'active');" class="btn btn-custom color3">发布</a>
                                        </if>
                                        <a type="button" href="javascript:;" onclick="return statusDailySign({$item['id']}, 'delete');" class="btn btn-custom color5">删除</a>
                                        <a type="button" href="/User/DailySign/setting?id={$item['id']}" class="btn btn-custom color6">分享设置</a>
                                        <a type="button" href="/User/DailySign/statistics?id={$item['id']}" class="btn btn-custom color9">数据分析</a>
                                    </td>
                                </tr>
                            </volist>
                            </tbody>
                        </table>
                    </div>
                    <div class="pages">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function statusDailySign(id, status){
        if(status === "active"){
            if(!confirm('确认发布吗？')) return false;
        }else if(status === "stop"){
            if(!confirm('确认停用吗？')) return false;
        }else{
            if(!confirm('确认删除吗？')) return false;
        }
        $.ajax({
            data: {id: id, status: status},
            dataType: 'json',
            url: '/User/DailySign/statusDailySign',
            type: 'get',
            success: function (res) {
                alert(res['info']);
                window.location.reload();
            }
        });
        return false;
    }
</script>